<?php
/**
 * Created by PhpStorm.
 * User: QM
 * Date: 2018/3/21
 * Time: 10:24
 */
namespace App\Controller;

use FOS\RestBundle\Controller\FOSRestController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;

/**
 * Class ApiController
 * @package App\Controller
 */
class ApiController extends FOSRestController
{
    /**
     * @Route("/api/index.{_format}",name="api_index")
     * @param string  $_format rest-bundle
     * @param Request $request
     * @return JsonResponse
     */
    public function index($_format, Request $request)
    {
        $userData = $this->get('security_token')->begin($request);
        if ($userData['code'] != 0) {
            $view = $this->view($userData)->setFormat($_format);

            return $this->handleView($view);
        }
        //$this->get("commen_mq")->writeMq(array(1,2,3));
        //$this->getParameter('cdr.config');

        $view = $this->view($userData)->setFormat($_format);

        return $this->handleView($view);
    }
}